FROM node:8.11-alpine AS builder

ARG NODE_ENV
ENV NODE_ENV=$NODE_ENV

WORKDIR /app

COPY ./package* ./
RUN npm install --registry=https://registry.npm.taobao.org && \
    npm cache clean --force

COPY . .
RUN npm run build


FROM nginx:stable-alpine

EXPOSE 80

COPY --from=builder /app/dist/ /var/www/
COPY ./docker/nginx/proxy_params /etc/nginx/proxy_params
COPY ./docker/nginx/default.conf /etc/nginx/conf.d/default.conf

CMD ["nginx", "-g", "daemon off;"]
